package vn.mobisoft.gachno;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;

public class Function {

	public static String getDateMonthYear() {
		SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
		String currentDateandTime = sdf.format(new Date());
		return currentDateandTime; 
	}
	
	public static String gethhmmss() {
		SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
		String currentDateandTime = sdf.format(new Date());
		return currentDateandTime; 
	}
	
	public static String getDateMonthYear1() {
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
		String currentDateandTime = sdf.format(new Date());
		return currentDateandTime; 
	}
	
	public static String getCKN() {
		SimpleDateFormat sdf = new SimpleDateFormat("MM/yyyy");
		String currentDateandTime = sdf.format(new Date());
		return currentDateandTime; 
	}
	
	public static String getYYYMMDD(int y, int m, int d) {
		m+=1;
		String result = ""+y;
		if (m<10 )result = result +"0"+m;
		else result+=m;
		
		if (d<10 )result = result +"0"+d;
		else result+=d;
		return result; 
	}
	
	public static String getddMMyy(int D, int M, int Y) {
		M+=1;
		String result = "";
		if (D<10 ) result = result +"0"+D;
		else result+=D;
		
		if (M<10 )result = result +"/0"+M;
		else result+="/"+M;
		
		result = result +"/"+Y;
		return result; 
	}

	public Vector<ClientItem> parseClientList(String result) {
		//2<br/>011522841:CTY TNHH TM DV DU LICH TRANG MAI:38519375:2105043:383916:73973778:2462774
		String[] a = result.split("<br/>");
		Vector<ClientItem> list = new Vector<ClientItem>();
		
		for (int i=0; i<a.length; i++) {
			if (a[i].length() >10) {
				String[] b = a[i].split(":");
				if (b.length>=7) {
					ClientItem ci = new ClientItem(b[0], b[1], b[2], b[3], b[4], b[5], b[6]);
					list.add(ci);
				}
			}
		}		
		return list;
	}

	public Vector<Report_item> parseReportList(String result) {
		String[] a = result.split("<br/>");
		Vector<Report_item> list = new Vector<Report_item>();
		
		for (int i=0; i<a.length; i++) {
			if (a[i].length() >10) {
				String[] b = a[i].split(":");
				if (b.length>=8) {
					Report_item ci = new Report_item(b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]);
					list.add(ci);
				}
			}
		}
		return list;
	}
	
	
	
}
